package com.ljx.controller;

import com.ljx.entitl.AliPay;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author LJX
 * @Description: TODO
 * @Date: 2022/11/15 16:45
 * @Version 1.0
 */
@RestController
public class HelloController {

	@GetMapping("hello")
	public Map<String,Object> hello(){
		Map<String, Object> map = new HashMap<>();
		map.put("name","李吉祥");
		map.put("age",14);
		return map;
	}


	/**
	 * 读取配置文件内容，将内容读取到实体类中
	 * 将实体类自动映射到控制层
	 */
	@Autowired
	private AliPay aliPay;

	@RequestMapping("entitl")
	private AliPay ali(){
		return aliPay;
	}

	/**
	 * 读取单个配置文件属性
	 * 在配置文件中自定义属性
	 * 然后在此通过@Value注解获取他的值
	 */

	@Value("${server.port}")
	private Integer port;
	@GetMapping("info")
	public String info(){
		return "端口号为"+port;
	}
}
